<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        // 可以让键名 变成任意数据类型
        // let m1 = new Map([
        //     ['a',1],
        //     ['b',2]
        // ]);

        // console.log(m1); //{'a' => 1, 'b' => 2}
        // let s1 = new Set([1,2,3,['a','b']]);

        // s1.add(new Map([['a','123']]))

        // console.log(s1);


        let arr = [1,2,3];
        let m2 = new Map([
            ['name','老王'],
            [function(){
                console.log(123);
            },'啦啦啦'],
            [arr,'18岁']
        ]);

        console.log(m2);

        console.log(m2.size); //3

        m2.set('ccc','888');

        console.log(m2);

        let val = m2.get('name');

        console.log(val);

        let res = m2.get(arr);

        console.log(res);

        // 键名的判断是否存在
        let bool = m2.has('888');

        console.log(bool);


        // 删除某个键和值

        let bool2 = m2.delete('cc2c')

        console.log(bool2);
        console.log(m2);


        // 清空map对象中的键值对
        // m2.clear()
        // console.log(m2);

        m2.forEach((val,key)=>{
            console.log(val);
            console.log(key);
        })







    </script>
</body>
</html>